<template>
    <div>
        标题:
        <input type="text" v-model="infof.name">
        分栏:
        <select v-model="infof.id" >
                            <option value="">请选择</option>
                            <option :value="o.lid" v-for="o in Von" >{{ o.lName }}</option>
                        </select>
        <input type="button" value="查询" @click="Show" >
        <table>
            <thead>
                <tr>
                    <td>标题</td>
                    <td>分栏标题</td>
                    <td>分栏</td>
                    <td>图片</td>
                    <td>价格</td>
                    <td>颜色</td>
                    <td>功能</td>
                </tr>

                <tr v-for="o in info.list ">
                    <td>{{ o.text }}</td>
                    <td>{{ o.fText }}</td>
                    <td>{{ o.lName }}</td>
                    <td><img :src="o.img" width="60" height="60" ></td>
                    <td>{{ o.money }}</td>
                    <td>{{ o.cole }}</td>
                    <td><input type="button" value="修改" @click="Upda(o.pid)" ></td>
                </tr>
            </thead>
        </table>
        <span>共{{ info.zt }}行</span>
        <span>共{{ info.zy }}页</span>
        <span>每页{{ infof.pazeseze }}行</span>
        <span>当前{{ infof.pazeinset }}/{{ info.zy }}页</span>
        <input type="button" value="首页" @click="Fan(1)" >
        <input type="button" value="上一页" @click="Fan(infof.pazeinset-1)" >
        <input type="button" :value="o" v-for="o in info.zy"  @click="Fan(o)" >
        <input type="button" value="下一页" @click="Fan(infof.pazeinset+1)" >
        <input type="button" value="尾页" @click="Fan(info.zy)" >
        
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';

const router=useRouter();

onMounted(()=>{
    List();
    Show();
})

let shu:any=ref([2,4,6]);

let Von:any=ref([]);

let infof:any=ref({
    name:"",
    id:'',
    pazeinset:"1",
    pazeseze:"3",
});

let info:any=ref({
    list:[],
    zt:0,
    zy:0
});

const Upda=(pid:any)=>{
    router.push({
        path:'/update',
        query:{
            id:pid
        }
    })
}


const Fan=(e:any)=>{
    console.log(e);
    infof.value.pazeinset=e;
    Show();
}

const List=()=>{
    axios({
        url:'https://localhost:7073/api/User/List',
        method:'get',
    })
    .then((res)=>{
        console.log(res);
        Von.value=res.data;        
    })
    
}
const Show=()=>{
    axios({
        url:'https://localhost:7073/api/User/Show',
        method:'get',
        params:infof.value
    })
    .then((res)=>{
        console.log(res);
        info.value=res.data;        
    })
    
}


</script>

<style scoped>

</style>
